package com.dropgame.main;

import java.lang.reflect.Array;
import java.util.ArrayList;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.utils.Json;
import com.badlogic.gdx.utils.Json.Serializable;
import com.badlogic.gdx.utils.ObjectMap;
import com.badlogic.gdx.utils.OrderedMap;

public class Profile implements Serializable{

	public int profileID;
	public boolean defaultProfile;
	public String name;
	public String test;
	public int volume;
	public int sfx;
	public boolean mute;
	
	public int numOfLevels = 2;
	
	
	public LevelNonSe[] levels = new LevelNonSe[numOfLevels];
	
	public Profile(){
		 
		 
		 for(int i = 0; i<numOfLevels; i++){
			 levels[i] = new LevelNonSe(i+1);
			 Gdx.app.log("Profile", "a level was added to the array : level" + i);
		   }
		 	 
	}

	@SuppressWarnings( "unchecked" )
	@Override
	public void read(Json json, OrderedMap<String, Object> jsonData) {
		profileID = json.readValue("profileID", Integer.class, jsonData);
		defaultProfile = json.readValue("defaultProfile", Boolean.class, jsonData);
		name = json.readValue("name", String.class, jsonData);
		test = json.readValue("the", String.class, jsonData);
		volume = json.readValue("volume", Integer.class, jsonData);
		sfx = json.readValue("sfx", Integer.class, jsonData);
		mute = json.readValue("mute", Boolean.class, jsonData);
		
		
		   
		   for(int i = 0; i<numOfLevels; i++){
			   levels[i].read(json, jsonData);
			   Gdx.app.log("Profile", "Level array position " + i + " was read");
		   }
			
	}

	@Override
	public void write(Json json) {
		json.writeValue("profileID", profileID);
		json.writeValue("defaultProfile", defaultProfile);
		json.writeValue("name", name);
		json.writeValue("the", test);
		json.writeValue("volume", volume);
		json.writeValue("sfx", sfx);
		json.writeValue("mute", mute);
		
	
		
		 for(int i = 0; i<numOfLevels; i++){
		 		levels[i].write(json);
		 		Gdx.app.log("Profile ", "Level array position " + i + " was written");
		 }
		 
		
	
	}

	
}
